home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / pdcurs21 / private / _gbiosky.c < prev    next >
C/C++ Source or Header  |  1993-06-20  |  3KB  |  101 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3.  
  4. #ifdef PDCDEBUG
  5. char *rcsid__gbiosky = "$Header: C:\CURSES\private\RCS\_gbiosky.c 2.1 1993/06/18 20:22:27 MH Rel MH $";
  6. #endif
  7.  
  8.  
  9.  
  10.  
  11. /*man-start*********************************************************************
  12.  
  13.   PDC_get_bios_key()    - Returns the next key available from the BIOS.
  14.  
  15.   PDCurses Description:
  16.      This is a private PDCurses routine.
  17.  
  18.      Returns the next key code struck at the keyboard. If the low 8
  19.      bits are 0, the upper bits contain the extended character
  20.      code. If bit 0-7 are non-zero, the upper bits = 0.
  21.  
  22.   PDCurses Return Value:
  23.      This function returns OK on success and ERR on error.
  24.  
  25.   PDCurses Errors:
  26.      No errors are defined for this function.
  27.  
  28.   Portability:
  29.      PDCurses    int PDC_get_bios_key( void );
  30.  
  31. **man-end**********************************************************************/
  32.  
  33. int    PDC_get_bios_key(void)
  34. {
  35. #ifdef    FLEXOS
  36. unsigned ch    = 0;
  37. #endif
  38.  
  39. #if    defined (DOS)
  40.     int ascii,scan;
  41.     static unsigned char keyboard_function=0xFF;
  42. #endif
  43.  
  44. #if    defined (OS2)
  45.     int ascii,scan;
  46.     KBDKEYINFO keyInfo;
  47. #endif
  48.  
  49. #ifdef PDCDEBUG
  50.     if (trace_on) PDC_debug("PDC_get_bios_key() - called\n");
  51. #endif
  52.  
  53. #ifdef    FLEXOS
  54.     retcode = s_read(0x00, 0L, (char *) &ch, 2L, 0L);
  55.     return( (retcode < 0L) ? ERR : ch );
  56. #endif
  57.  
  58. #if    defined (DOS)
  59.     if (keyboard_function == 0xFF)
  60.         {
  61.         regs.h.ah = 0x02;             /* get shift status for all keyboards */
  62.         int86(0x16, ®s, ®s);
  63.         scan = regs.h.al;
  64.         regs.h.ah = 0x12;             /* get shift status for enhanced keyboards */
  65.         int86(0x16, ®s, ®s);
  66.         if (scan == regs.h.al
  67.         &&  getdosmembyte(0x496) == 0x10)
  68.             keyboard_function = 0x10;
  69.         else
  70.             keyboard_function = 0x0;
  71.         }
  72.     regs.h.ah = keyboard_function;
  73.     int86(0x16, ®s, ®s);
  74.     ascii = regs.h.al;
  75.     scan = regs.h.ah;
  76. #endif
  77.  
  78. #ifdef    OS2
  79.     KbdCharIn(&keyInfo, IO_WAIT, 0);    /* get a character    */
  80.     ascii = keyInfo.chChar;
  81.     scan = keyInfo.chScan;
  82. #endif
  83.  
  84. #if    defined (DOS) || defined (OS2)
  85.     if (scan == 0x1c && ascii == 0x0a)  /* ^Enter */
  86.         return ((int) (0xfc00));
  87.     if ((scan == 0x03 && ascii == 0x00)  /* ^@ - Null */
  88.     ||  (scan == 0xe0 && ascii == 0x0d)  /* PadEnter */
  89.     ||  (scan == 0xe0 && ascii == 0x0a)) /* ^PadEnter */
  90.         return ((int) (ascii << 8));
  91.     if ((scan == 0x37 && ascii == 0x2a)  /* Star */
  92.     ||  (scan == 0x4a && ascii == 0x2d)  /* Minus */
  93.     ||  (scan == 0x4e && ascii == 0x2b)  /* Plus */
  94.     ||  (scan == 0xe0 && ascii == 0x2f)) /* Slash */
  95.         return ((int) ((ascii & 0x0f) | 0xf0) << 8);
  96.     if (ascii == 0x00 || ascii == 0xe0)
  97.         return ((int) (scan << 8));
  98.     return ((int) (ascii));
  99. #endif
  100. }
  101.